#pragma once
#include"RBTree.h"
namespace yh {
	template<class K>
	class set {
		struct SetKeyOfT {
			const K& operator()(const K& key) {
				return key;
			}
		};
	public:
		typedef typename RBTree<K, const K, SetKeyOfT>::iterator iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::const_iterator const_iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::reverse_iterator reverse_iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::const_reverse_iterator const_reverse_iterator;
		const_iterator cbegin()const {
			return _t.cbegin();
		}
		const_iterator cend()const {
			return _t.cend();
		}

		iterator begin() {
			return _t.begin();
		}
		iterator end() {
			return _t.end();
		}

		reverse_iterator rbegin() {
			return _t.rbegin();
		}
		reverse_iterator rend() {
			return _t.rend();
		}

		const_reverse_iterator crbegin()const {
			return _t.crbegin();
		}
		const_reverse_iterator crend()const {
			return _t.crend();
		}

		pair<iterator, bool> insert(const K& key) {
			return _t.insert(key);
		}
	private:
		RBTree<K, const K,SetKeyOfT> _t;
	};

	void test_set1() {
		int a[] = { 1,2,3,4,5,6,7,8,9,10 };
		set<int> s1;
		for (int i = 0; i < 10; i++) {
			s1.insert(a[i]);
		}
		set<int>::const_reverse_iterator it = s1.crbegin();
		while (it != s1.crend()) {
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}
